﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace Urb.Weather.MSN
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "MSN")]
    public class MSNWeatherUri
    {
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
        public MSNWeatherUri(string weatherLocationCode, string culture = "en-US")
        {
            WeatherLocationCode = weatherLocationCode;
            Culture = culture;
        }

        public string WeatherLocationCode { get; private set; }
        public string Culture { get; private set; }

        public override string ToString()
        {
            if (!string.IsNullOrWhiteSpace(WeatherLocationCode))
            {
                if (!string.IsNullOrWhiteSpace(Culture))
                    return string.Format(CultureInfo.InvariantCulture, "http://weather.service.msn.com/data.aspx?culture={0}&wealocations={1}", Culture, WeatherLocationCode);
                else
                    return string.Format(CultureInfo.InvariantCulture, "http://weather.service.msn.com/data.aspx?wealocations={0}", WeatherLocationCode);
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(Culture))
                    return string.Format(CultureInfo.InvariantCulture, "http://weather.service.msn.com/data.aspx?culture={0}", Culture);
                else
                    return "http://weather.service.msn.com/data.aspx";
            }
        }
    }
}
